/*
 * 官网地站:http://www.mob.com
 * 技术支持QQ: 4006852216
 * 官方微信:ShareSDK   （如果发布新版本的话，我们将会第一时间通过微信将版本更新内容推送给您。如果使用过程中有任何问题，也可以通过微信与我们取得联系，我们将会在24小时内给予回复）
 *
 * Copyright (c) 2013年 mob.com. All rights reserved.
 */

package com.renwei.yunlong.cn.sharesdk.onekeyshare.themes.classic;

import android.content.Context;
import android.content.res.Configuration;

import com.renwei.yunlong.cn.sharesdk.onekeyshare.OnekeyShareThemeImpl;
import com.renwei.yunlong.cn.sharesdk.onekeyshare.themes.classic.land.EditPageLand;
import com.renwei.yunlong.cn.sharesdk.onekeyshare.themes.classic.land.PlatformPageLand;
import com.renwei.yunlong.cn.sharesdk.onekeyshare.themes.classic.port.EditPagePort;
import com.renwei.yunlong.cn.sharesdk.onekeyshare.themes.classic.port.PlatformPagePort;

import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.Platform.ShareParams;

/**
 * 九宫格经典主题样式的实现类
 */
public class ClassicTheme extends OnekeyShareThemeImpl {

    /**
     * 展示平台列表
     */

    // 两次弹出九宫格间隔不能少于1000毫秒
    private static final int MIN_CLICK_DELAY_TIME = 1000;
    private static long lastTime;

    @Override
    protected void showPlatformPage(Context context) {
        PlatformPage page;
        int orientation = context.getResources().getConfiguration().orientation;
        if (orientation == Configuration.ORIENTATION_PORTRAIT) {
            page = new PlatformPagePort(this);
        } else {
            page = new PlatformPageLand(this);
        }
        long currentTime = System.currentTimeMillis();
        if ((currentTime - lastTime) >= MIN_CLICK_DELAY_TIME) {
            page.show(context, null);
        }
        lastTime = currentTime;

    }

    /**
     * 展示编辑界面
     */
    @Override
    protected void showEditPage(Context context, Platform platform, ShareParams sp) {
        EditPage page;
        int orientation = context.getResources().getConfiguration().orientation;
        if (orientation == Configuration.ORIENTATION_PORTRAIT) {
            page = new EditPagePort(this);
        } else {
            page = new EditPageLand(this);
        }
        page.setPlatform(platform);
        page.setShareParams(sp);
        page.show(context, null);
    }

}
